<HTML><HEAD><TITLE>seek(+Stream, +Offset)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Stream I/O</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>seek(+Stream, +Offset)</H1>
The pointer in stream Stream is offset Offset from the start of the file
<DL>
<DT><EM>Stream</EM></DT>
<DD>Integer (stream number) or Atom (reserved or user-defined symbolic stream name).
</DD>
<DT><EM>Offset</EM></DT>
<DD>Integer or the atom end_of_file.
</DD>
</DL>
<H2>Description</H2>
   Moves the file pointer to offset Offset from the start of the file
   opened.  It is an error if Stream is not a stream or if Offset is not an
   integer or the atom end_of_file.

<P>
   seek/2 seeks to the end of the file when Offset is instantiated to
   end_of_file.

<P>
   seek/2 has no effect on the null stream, it always succeeds.

<P>

<H3>Modes and Determinism</H3><UL>
<LI>seek(+, +) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Either Stream or Offset is uninstantiated.
<DT><EM>(5) type error </EM>
<DD>Offset is instantiated, but not to an integer or the atom    end_of_file.
<DT><EM>(5) type error </EM>
<DD>Stream is instantiated, but not to an atom or an integer.
<DT><EM>(6) out of range </EM>
<DD>Offset is a negative integer or greater than the file    length.
<DT><EM>(192) illegal stream mode </EM>
<DD>Stream is in an illegal stream mode.
<DT><EM>(193) illegal stream specification </EM>
<DD>Stream is an illegal stream specification.
</DL>
<H2>Examples</H2>
<PRE>
Success:
      seek( 0,null). % does not modify, only succeeds

      [eclipse]: open(file1,update,s), write(s,hello),
      &gt; seek(s,3), read(s,T), close(s).
      T = lo
      yes.

Error:
      seek( Offset,7).      (Error 4).
      seek("7", 2).         (Error 5).
      seek(7, -1).          (Error 6).
      seek( 0,input).       (Error 192).
      seek(-1, 0).          (Error 193). % does not exist



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/iostream/at-2.html">at / 2</A>, <A HREF="../../kernel/iostream/at_eof-1.html">at_eof / 1</A>, <A HREF="../../kernel/iostream/set_stream_property-3.html">set_stream_property / 3</A>
</BODY></HTML>
